package qianting.news.article.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import qianting.news.apis.models.comment.dtos.CommentDto;
import qianting.news.apis.models.comment.dtos.CommentLikeDto;
import qianting.news.apis.models.comment.dtos.CommentSaveDto;
import qianting.news.article.service.CommentService;
import qianting.news.common.entity.State;

@Api(tags = "文章评论管理")
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @ApiOperation(value = "保存文章评论")
    @PostMapping("/save")
    public State saveComment(@RequestBody CommentSaveDto dto){
        return commentService.saveComment(dto);
    }

    @ApiOperation(value = "点赞文章评论")
    @PostMapping("/like")
    public State like(@RequestBody CommentLikeDto dto){
        return commentService.like(dto);
    }

    @ApiOperation(value = "加载文章评论")
    @PostMapping("/load")
    public State findByArticleId(@RequestBody CommentDto dto){
        return commentService.findByArticleId(dto);
    }
}
